package org.sivan.game.resources;

import javax.imageio.ImageIO;
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

/**
 * Created by 湛兮 on 2017/2/14.
 */
public class HRes {
    public static AudioClip openMusic(String file) {
        URL fileURL = HRes.class.getResource(file);
        return Applet.newAudioClip(fileURL);
    }

    public static BufferedImage openImage(String file) {
        BufferedImage image = null;
        try {
            image = ImageIO.read(HRes.class.getResourceAsStream(file));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return image;
    }
}
